﻿using HMEngine.HMEffects;
using Microsoft.Xna.Framework;

using HMEngine.HMObjects;
using Microsoft.Xna.Framework.Graphics;

namespace HMEngine.HMComponents {
    public abstract class IHMHasMaterial : HMObject, IHMComponent {
        public Vector3 AmbientColor { get; set; }
        public Vector3 DiffuseColor { get; set; }
        public float SpecularPower { get; set; }

        protected IHMHasMaterial() {
            AmbientColor = new Vector3(0.15f);
            DiffuseColor = new Vector3(0.25f);
            SpecularPower = 8;
        }

        internal void SetMaterialProperties() {
            Effect effect = HMEffectManager.ActiveShader.Effect;

            if (null != effect.Parameters["AmbientColor"]) effect.Parameters["AmbientColor"].SetValue(AmbientColor);
            if (null != effect.Parameters["DiffuseColor"]) effect.Parameters["DiffuseColor"].SetValue(DiffuseColor);
            if (null != effect.Parameters["SpecularPower"]) effect.Parameters["SpecularPower"].SetValue(SpecularPower);
        }
    }
}